package com.example.xt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.xt.entity.Rder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2022-03-05
 */
@Mapper
public interface RderMapper extends BaseMapper<Rder> {
    @Select("SELECT * FROM rder where medicine=#{medicine}")
    List<Rder> getrder(Integer medicine);

    @Update("UPDATE medicine as m JOIN rder as r JOIN orders as o SET m.stock=m.stock+r.num,o.rent=\"已退货\" WHERE m.id=r.id AND r.medicine=o.medicine AND r.medicine=#{medicine}")
    boolean rent(Integer medicine);
}
